home *** CD-ROM | disk | FTP | other *** search
- (*************************************************************************
-
- $RCSfile: OL.mod $
- Description: Recursively scans the symbol files referenced by a module
- and creates a WITH file to be input to a linker.
-
- Created by: fjc (Frank Copeland)
- $Revision: 2.8 $
- $Author: fjc $
- $Date: 1995/01/26 02:07:58 $
-
- Copyright © 1993-1995, Frank Copeland
- This module forms part of the OL program
- See OL.doc for conditions of use and distribution
-
- Log entries are at the end of the file.
-
- *************************************************************************)
-
- <* STANDARD- *>
-
- MODULE OL;
-
- IMPORT
- SYS := SYSTEM, Kernel, OLRev, Errors, e := Exec, d := Dos,
- du := DosUtil, str := Strings, str2 := Strings2, f := Files,
- L := Lists, OLSettings, s := OLStrings, u := Utility, wb := Workbench,
- i := Icon, WbConsole;
-
- CONST
- CopyrightStr = "Copyright © 1993-1995 Frank Copeland\n";
-
- VAR
- startDir : d.FileLockPtr;
-
- (*
- ** Command line template and parsing
- *)
-
- CONST
- template =
- "PROG/A,SETTINGS/K,SYMSEARCH/K,OBJSEARCH/K,"
- "WITHPATH/K,PROGPATH/K,SYMEXT/K,OBJEXT/K,WITHEXT/K,"
- "LINKCMD/K,LINKARGS/K,ALINK/S,BLINK/S,DLINK/S,"
- "VERBOSE/S,MAKEICONS/S,QUIET/S,NOICONS/S,SCAN/S,LINK/S";
-
- template2 = "STR/M";
-
- helpStr =
- "See OL.doc for more details\n\n"
- "Arguments ? ";
-
- optPROG = 0;
- optSETTINGS = 1;
- optSYMSEARCH = 2;
- optOBJSEARCH = 3;
- optWITHPATH = 4;
- optPROGPATH = 5;
- optSYMEXT = 6;
- optOBJEXT = 7;
- optWITHEXT = 8;
- optLINKCMD = 9;
- optLINKARGS = 10;
- optALINK = 11;
- optBLINK = 12;
- optDLINK = 13;
- optVERBOSE = 14;
- optMAKEICONS = 15;
- optQUIET = 16;
- optNOICONS = 17;
- optSCAN = 18;
- optLINK = 19;
- optCount = 20;
-
- VAR
- rdArgs, rdArgs2 : d.RDArgsPtr;
- args : RECORD [2] (d.ArgsStruct)
- prog,
- settings,
- symsearch,
- objsearch,
- withpath,
- progpath,
- symext,
- objext,
- withext,
- linkcmd,
- linkargs
- : d.ArgString;
- alink,
- blink,
- dlink,
- verbose,
- makeicons,
- quiet,
- noicons,
- scan,
- link
- : d.ArgBool;
- END;
-
- CONST
- maxName = 255;
- maxPath = 255;
-
- TYPE
- NameStr = ARRAY maxName + 1 OF CHAR;
- PathStr = ARRAY maxPath + 1 OF CHAR;
-
- (* These are filled in by ParseArgs() *)
-
- VAR
- moduleName : NameStr;
- withName, progName : PathStr;
- Scan, Link : BOOLEAN;
-
- TYPE
- StringArray = POINTER [2] TO ARRAY MAX(INTEGER) OF e.LSTRPTR;
-
- (*
- ** Symbol files
- *)
-
- CONST
- SymTag = 53594D08H; (* Symbol file tag : "SYM" + version # *)
-
- (* terminal symbols for symbol file elements *)
-
- eUndef = 0; eCon = 1; eTypE = 2; eTyp = 3; eVar = 4; eXProc = 5;
- eLibCall = 6; eM2Proc = 7; eCProc = 8; eAProc = 9; ePointer = 10;
- eProcTyp = 11; eArray = 12; eDynArr = 13; eRecord = 14; eParList = 15;
- eValPar = 16; eVarPar = 17; eVarArg = 18; eFldList = 19; eFld = 20;
- eHPtr = 21; eHProc = 22; eTProcE = 23; eTProc = 24; eFixup = 25;
- eMod = 26; eExtLib = 27;
-
- (*
- ** Module list
- *)
-
- TYPE
- ModulePtr = POINTER TO Module;
- Module = RECORD (L.NameNode)
- key : LONGINT;
- path : PathStr;
- END; (* Module *)
-
- VAR
- moduleList : L.NameList;
-
- (*
- ** File searching
- *)
-
- CONST
- maxSearch = 10;
- maxExt = 10;
-
- VAR
- SymSearch, ObjSearch : ARRAY maxSearch + 1 OF e.LSTRPTR;
- SymExt, ObjExt : ARRAY maxExt + 1 OF e.LSTRPTR;
- SymX, ObjX, SymExtX, ObjExtX : INTEGER;
-
- (*
- ** Icon types
- *)
-
- CONST
- iconWith = 0; iconProg = 1;
-
- (*
- ** Console I/O
- *)
-
- (*------------------------------------*)
- PROCEDURE OutStr* ( string : ARRAY OF CHAR );
- <*$CopyArrays-*>
- BEGIN (* OutStr *)
- du.HaltIfBreak ({d.ctrlC});
- IF d.PutStr (string) = 0 THEN END;
- END OutStr;
-
-
- (*------------------------------------*)
- PROCEDURE OutChar* ( c : CHAR );
- BEGIN (* OutChar *)
- du.HaltIfBreak ({d.ctrlC});
- d.PrintF ("%lc", c)
- END OutChar;
-
-
- (*------------------------------------*)
- PROCEDURE OutLn*;
- BEGIN (* OutLn *)
- OutChar ("\n")
- END OutLn;
-
-
- (*------------------------------------*)
- PROCEDURE OutStr0* ( n : LONGINT );
- VAR string : e.LSTRPTR;
- BEGIN (* OutStr0 *)
- du.HaltIfBreak ({d.ctrlC});
- string := s.GetString (n);
- IF d.PutStr (string^) = 0 THEN END;
- END OutStr0;
-
-
- (*------------------------------------*)
- PROCEDURE OutStr1* ( n : LONGINT; string : ARRAY OF CHAR );
- VAR format : e.LSTRPTR;
- <*$CopyArrays-*>
- BEGIN (* OutStr1 *)
- du.HaltIfBreak ({d.ctrlC});
- format := s.GetString (n);
- d.PrintF (format^, SYS.ADR (string));
- END OutStr1;
-
-
- (*------------------------------------*)
- PROCEDURE OutBool* ( b : BOOLEAN );
- BEGIN (* OutBool *)
- IF b THEN OutStr ("TRUE")
- ELSE OutStr ("FALSE")
- END
- END OutBool;
-
-
- (*------------------------------------*)
- PROCEDURE* Cleanup (VAR rc : LONGINT);
-
- VAR oldDir : d.FileLockPtr;
-
- BEGIN (* Cleanup *)
- IF rdArgs # NIL THEN
- d.FreeArgs (rdArgs);
- d.FreeDosObject (d.rdArgs, rdArgs);
- rdArgs := NIL
- END;
- IF rdArgs2 # NIL THEN
- d.FreeDosObject (d.rdArgs, rdArgs2);
- rdArgs2 := NIL
- END;
- s.CloseCatalog();
- IF Kernel.fromWorkbench THEN oldDir := d.CurrentDir (startDir) END
- END Cleanup;
-
- (*------------------------------------*)
- PROCEDURE Init ();
-
- BEGIN (* Init *)
- Kernel.SetCleanup (Cleanup);
- s.OpenCatalog (NIL, "");
-
- rdArgs := d.AllocDosObjectTags (d.rdArgs, u.end);
- rdArgs2 := d.AllocDosObjectTags (d.rdArgs, u.end);
- ASSERT ((rdArgs # NIL) & (rdArgs2 # NIL));
- rdArgs.extHelp := SYS.ADR (helpStr);
- END Init;
-
- (*------------------------------------*)
- PROCEDURE CloneStr ( oldStr : e.LSTRPTR ) : e.LSTRPTR;
- VAR newStr : e.LSTRPTR;
- BEGIN (* CloneStr *)
- SYS.NEW (newStr, str.Length (oldStr^) + 1);
- COPY (oldStr^, newStr^);
- RETURN newStr
- END CloneStr;
-
- (*------------------------------------*)
- PROCEDURE WbArgs ();
-
- VAR
- wbStartup : wb.WBStartupPtr;
- numArgs : LONGINT;
- argList : wb.WBArgumentsPtr;
- oldDir : d.FileLockPtr;
- diskObj : wb.DiskObjectPtr;
- toolTypes : wb.ToolTypePtr;
- string : e.LSTRPTR;
-
- BEGIN (* WbArgs *)
- wbStartup := SYS.VAL (wb.WBStartupPtr, Kernel.WBenchMsg);
- numArgs := wbStartup.numArgs;
- argList := wbStartup.argList;
- IF numArgs > 2 THEN OutStr0 (s.msg23); HALT (d.warn) END;
-
- IF i.base # NIL THEN
- (* Attempt to load the icon for OL *)
- startDir := d.CurrentDir (argList[0].lock);
- diskObj := i.GetDiskObject (argList[0].name^);
- IF diskObj # NIL THEN
- toolTypes := diskObj.toolTypes;
- string := i.FindToolType (toolTypes, "PROG");
- IF string # NIL THEN args.prog := CloneStr (string) END;
- string := i.FindToolType (toolTypes, "SETTINGS");
- IF string # NIL THEN args.settings := CloneStr (string) END;
- string := i.FindToolType (toolTypes, "SYMSEARCH");
- IF string # NIL THEN args.symsearch := CloneStr (string) END;
- string := i.FindToolType (toolTypes, "OBJSEARCH");
- IF string # NIL THEN args.objsearch := CloneStr (string) END;
- string := i.FindToolType (toolTypes, "WITHPATH");
- IF string # NIL THEN args.withpath := CloneStr (string) END;
- string := i.FindToolType (toolTypes, "PROGPATH");
- IF string # NIL THEN args.progpath := CloneStr (string) END;
- string := i.FindToolType (toolTypes, "SYMEXT");
- IF string # NIL THEN args.symext := CloneStr (string) END;
- string := i.FindToolType (toolTypes, "OBJEXT");
- IF string # NIL THEN args.objext := CloneStr (string) END;
- string := i.FindToolType (toolTypes, "WITHEXT");
- IF string # NIL THEN args.withext := CloneStr (string) END;
- string := i.FindToolType (toolTypes, "LINKCMD");
- IF string # NIL THEN args.linkcmd := CloneStr (string) END;
- string := i.FindToolType (toolTypes, "LINKARGS");
- IF string # NIL THEN args.linkargs := CloneStr (string) END;
- string := i.FindToolType (toolTypes, "ALINK");
- IF string # NIL THEN args.alink := e.LTRUE END;
- string := i.FindToolType (toolTypes, "BLINK");
- IF string # NIL THEN args.blink := e.LTRUE END;
- string := i.FindToolType (toolTypes, "DLINK");
- IF string # NIL THEN args.dlink := e.LTRUE END;
- string := i.FindToolType (toolTypes, "VERBOSE");
- IF string # NIL THEN args.verbose := e.LTRUE END;
- string := i.FindToolType (toolTypes, "MAKEICONS");
- IF string # NIL THEN args.makeicons := e.LTRUE END;
- string := i.FindToolType (toolTypes, "QUIET");
- IF string # NIL THEN args.quiet := e.LTRUE END;
- string := i.FindToolType (toolTypes, "NOICONS");
- IF string # NIL THEN args.noicons := e.LTRUE END;
- string := i.FindToolType (toolTypes, "SCAN");
- IF string # NIL THEN args.scan := e.LTRUE END;
- string := i.FindToolType (toolTypes, "LINK");
- IF string # NIL THEN args.link := e.LTRUE END;
-
- i.FreeDiskObject (diskObj)
- END
- END;
-
- oldDir := d.CurrentDir (argList[numArgs-1].lock);
- IF args.prog = NIL THEN
- IF numArgs = 2 THEN args.prog := argList[numArgs-1].name
- ELSE OutStr0 (s.msg29); HALT (d.warn)
- END
- END
- END WbArgs;
-
- (*------------------------------------*)
- PROCEDURE CliArgs ();
- VAR ignore : BOOLEAN;
- BEGIN (* CliArgs *)
- IF d.ReadArgs (template, args, rdArgs) = NIL THEN
- ignore := d.PrintFault (d.IoErr(), "ReadArgs");
- HALT (d.warn)
- END
- END CliArgs;
-
- (*------------------------------------*)
- PROCEDURE ParseArgs ();
-
- VAR
- ignore : BOOLEAN; ch : CHAR;
- args2 : RECORD [2] (d.ArgsStruct)
- strings : d.ArgStringArray
- END;
-
- (*------------------------------------*)
- PROCEDURE ParseString (s : ARRAY OF CHAR);
-
- VAR len : LONGINT; buffer : e.LSTRPTR;
-
- <*$CopyArrays-*>
- BEGIN (* ParseString *)
- len := str.Length (s) + 2;
- SYS.NEW (buffer, len);
- COPY (s, buffer^);
- buffer [len-2] := "\n"; buffer [len-1] := 0X;
- rdArgs2.source.buffer := buffer;
- rdArgs2.source.length := len - 1;
- rdArgs2.source.curChr := 0;
- rdArgs2.daList := 0; rdArgs2.buffer := NIL; rdArgs2.bufSiz := 0;
- rdArgs2.extHelp := NIL; rdArgs2.flags := {};
- args2.strings := NIL;
- IF d.ReadArgs (template2, args2, rdArgs2) = NIL THEN
- ignore := d.PrintFault (d.IoErr(), "ParseString");
- HALT (d.warn)
- END
- END ParseString;
-
-
- (*------------------------------------*)
- PROCEDURE AddSearchPaths
- ( VAR paths : ARRAY OF e.LSTRPTR;
- VAR pathx : INTEGER;
- limit : INTEGER;
- errMsg : INTEGER;
- string : ARRAY OF CHAR );
-
- VAR i : INTEGER;
-
- <*$CopyArrays-*>
- BEGIN (* AddSearchPaths *)
- paths [0] := NIL; pathx := 0;
- ParseString (string);
- IF args2.strings # NIL THEN
- i := 0;
- WHILE args2.strings [i] # NIL DO
- IF du.DirExists (args2.strings [i]^) THEN
- IF pathx >= (limit-1) THEN OutStr0 (s.msg2); HALT (d.warn) END;
- paths [pathx] := CloneStr (args2.strings [i]);
- INC (pathx)
- ELSE
- OutStr1 (errMsg, args2.strings [i]^); HALT (d.warn)
- END;
- INC (i)
- END;
- END;
- paths [pathx] := SYS.ADR ("OLIB:"); INC (pathx);
- d.FreeArgs (rdArgs2);
- END AddSearchPaths;
-
- (*------------------------------------*)
- PROCEDURE AddExtensions
- ( VAR extensions : ARRAY OF e.LSTRPTR;
- VAR extx : INTEGER;
- limit : INTEGER;
- string : ARRAY OF CHAR );
-
- VAR i : INTEGER;
-
- <*$CopyArrays-*>
- BEGIN (* AddExtensions *)
- extensions [0] := NIL; extx := 0;
- ParseString (string);
- IF args2.strings # NIL THEN
- i := 0;
- WHILE args2.strings [i] # NIL DO
- IF extx >= limit THEN OutStr0 (s.msg7); HALT (d.warn) END;
- extensions [extx] := CloneStr (args2.strings [i]);
- INC (extx);
- INC (i)
- END;
- END;
- d.FreeArgs (rdArgs2);
- END AddExtensions;
-
- BEGIN (* ParseArgs *)
- COPY (args.prog^, moduleName);
-
- IF args.settings = NIL THEN ignore := OLSettings.LoadPrefs ("OL.prefs")
- ELSE
- IF ~OLSettings.LoadPrefs (args.settings^) THEN
- OutStr1 (s.msg1, args.settings^);
- HALT (d.warn)
- END
- END;
-
- IF args.symsearch # NIL THEN COPY (args.symsearch^, OLSettings.SymSearch)
- END;
- AddSearchPaths
- (SymSearch, SymX, maxSearch, s.msg3, OLSettings.SymSearch);
-
- IF args.objsearch # NIL THEN COPY (args.objsearch^, OLSettings.ObjSearch)
- END;
- AddSearchPaths
- (ObjSearch, ObjX, maxSearch, s.msg4, OLSettings.ObjSearch);
-
- IF args.withpath # NIL THEN COPY (args.withpath^, OLSettings.WithPath)
- END;
- IF ~du.DirExists (OLSettings.WithPath) THEN
- OutStr1 (s.msg5, OLSettings.WithPath);
- HALT (d.warn)
- END;
-
- IF args.progpath # NIL THEN COPY (args.progpath^, OLSettings.ProgPath)
- END;
- IF ~du.DirExists (OLSettings.ProgPath) THEN
- OutStr1 (s.msg6, OLSettings.ProgPath);
- HALT (d.warn)
- END;
-
- IF args.symext # NIL THEN COPY (args.symext^, OLSettings.SymExt) END;
- AddExtensions (SymExt, SymExtX, maxExt, OLSettings.SymExt);
-
- IF args.objext # NIL THEN COPY (args.objext^, OLSettings.ObjExt) END;
- AddExtensions (ObjExt, ObjExtX, maxExt, OLSettings.ObjExt);
-
- IF args.withext # NIL THEN COPY (args.withext^, OLSettings.WithExt) END;
-
- IF args.linkcmd # NIL THEN COPY (args.linkcmd^, OLSettings.LinkCmd) END;
-
- IF args.linkargs # NIL THEN COPY (args.linkargs^, OLSettings.LinkArgs)
- END;
-
- IF
- ((args.alink = e.LTRUE)
- & ((args.blink = e.LTRUE) OR (args.dlink = e.LTRUE)))
- OR ((args.blink = e.LTRUE)
- & ((args.alink = e.LTRUE) OR (args.dlink = e.LTRUE)))
- OR ((args.dlink = e.LTRUE)
- & ((args.alink = e.LTRUE) OR (args.blink = e.LTRUE)))
- THEN
- OutStr0 (s.msg24); HALT (d.warn)
- ELSIF (args.alink = e.LTRUE) THEN OLSettings.WithFmt := OLSettings.ALink
- ELSIF (args.blink = e.LTRUE) THEN OLSettings.WithFmt := OLSettings.BLink
- ELSIF (args.dlink = e.LTRUE) THEN OLSettings.WithFmt := OLSettings.DLink
- END;
-
- IF (args.verbose = e.LTRUE) & (args.quiet = e.LTRUE) THEN
- OutStr0 (s.msg25); HALT (d.warn)
- ELSIF (args.verbose = e.LTRUE) THEN OLSettings.Verbose := TRUE
- ELSIF (args.quiet = e.LTRUE) THEN OLSettings.Verbose := FALSE
- END;
-
- IF (args.makeicons = e.LTRUE) & (args.noicons = e.LTRUE) THEN
- OutStr0 (s.msg26); HALT (d.warn)
- ELSIF (args.makeicons = e.LTRUE) THEN OLSettings.MakeIcons := TRUE
- ELSIF (args.noicons = e.LTRUE) THEN OLSettings.MakeIcons := FALSE
- END;
-
- Scan := (args.scan = e.LTRUE);
- Link := (args.link = e.LTRUE);
-
- COPY (OLSettings.WithPath, withName);
- IF d.AddPart (withName, moduleName, LEN (withName)) THEN
- str.Append (OLSettings.WithExt, withName)
- ELSE
- OutStr0 (s.msg9); HALT (d.warn)
- END;
-
- COPY (OLSettings.ProgPath, progName);
- IF ~d.AddPart (progName, moduleName, LEN (progName)) THEN
- OutStr0 (s.msg22); HALT (d.warn)
- END
- END ParseArgs;
-
- (*------------------------------------*)
- PROCEDURE MakeIcon ( file : ARRAY OF CHAR; type : INTEGER );
-
- VAR
- icon, defIcon : PathStr;
- diskObj : wb.DiskObjectPtr;
-
- <*$CopyArrays-*>
- BEGIN (* MakeIcon *)
- IF OLSettings.MakeIcons THEN
- ASSERT (i.base # NIL, 100);
- COPY (file, icon); str.Append (".info", icon);
- IF ~du.FileExists (icon) THEN
- CASE type OF
- iconWith : COPY ("ENV:OL/def_with", defIcon) |
- iconProg : COPY ("ENV:OL/def_prog", defIcon) |
- END;
- diskObj := i.GetDiskObject (defIcon);
- IF diskObj = NIL THEN
- IF type = iconWith THEN diskObj := i.GetDefDiskObject (wb.project)
- ELSE diskObj := i.GetDefDiskObject (wb.tool)
- END
- END;
- IF diskObj # NIL THEN
- diskObj.currentX := wb.noIconPosition;
- diskObj.currentY := wb.noIconPosition;
- IF ~i.PutDiskObject (file, diskObj) THEN
- IF d.PrintFault (d.IoErr(), "PutDiskObject") THEN END;
- OutStr1 (s.msg27, icon)
- END;
- i.FreeDiskObject (diskObj)
- ELSE
- IF d.PrintFault (d.IoErr(), "GetDiskObject") THEN END;
- OutStr0 (s.msg28)
- END
- END
- END
- END MakeIcon;
-
-
- (*------------------------------------*)
- PROCEDURE Main ();
-
- (*------------------------------------*)
- PROCEDURE Process (modName : ARRAY OF CHAR; key : LONGINT);
-
- VAR
- name : NameStr; symPath, objPath : PathStr;
- node : L.NodePtr; module : ModulePtr;
- symFile : f.File; r : f.Rider;
- si : SHORTINT; i : INTEGER; l, modKey : LONGINT; ch : CHAR;
-
- (*------------------------------------*)
- PROCEDURE ReadName (VAR n : ARRAY OF CHAR);
-
- VAR i : SHORTINT; ch : CHAR;
-
- BEGIN (* ReadName *)
- i := 0;
- LOOP
- f.Read (r, ch); n [i] := ch;
- IF ch = 0X THEN EXIT END;
- INC (i);
- IF i > maxName THEN OutStr1 (s.msg10, symPath); HALT (d.warn) END
- END
- END ReadName;
-
- (*------------------------------------*)
- PROCEDURE ReadModAnchor
- ( VAR k : LONGINT;
- VAR n : ARRAY OF CHAR );
-
- BEGIN (* ReadModAnchor *)
- f.ReadBytes (r, k, 4); (* key *)
- ReadName (n)
- END ReadModAnchor;
-
- (*------------------------------------*)
- PROCEDURE NewModule
- ( name, path : ARRAY OF CHAR;
- key : LONGINT );
-
- VAR module : ModulePtr;
-
- <*$CopyArrays-*>
- BEGIN (* NewModule *)
- NEW (module); module.Name (name);
- module.key := key; COPY (path, module.path);
- moduleList.AddTail (module)
- END NewModule;
-
- (*------------------------------------*)
- PROCEDURE Search
- ( VAR paths, extensions : ARRAY OF e.LSTRPTR;
- name : ARRAY OF CHAR;
- VAR path : ARRAY OF CHAR )
- : BOOLEAN;
-
- VAR temp : NameStr; i : INTEGER;
-
- BEGIN (* Search *)
- i := 0;
- LOOP
- IF extensions [i] = NIL THEN RETURN FALSE END;
- COPY (name, temp); str.Append (extensions [i]^, temp);
- IF du.Search (paths, temp, path) THEN RETURN TRUE END;
- INC (i)
- END
- END Search;
-
- <*$CopyArrays-*>
- BEGIN (* Process *)
- node := moduleList.Find (modName);
- IF node = NIL THEN
- IF Search (SymSearch, SymExt, modName, symPath) THEN
- IF Search (ObjSearch, ObjExt, modName, objPath) THEN
- symFile := f.Old (symPath);
- IF symFile = NIL THEN OutStr1 (s.msg11, symPath); HALT (d.warn)
- END;
-
- OutStr ("\x9B\x4B << "); OutStr (symPath); OutChar (0DX);
- f.Set (r, symFile, 0);
- f.ReadBytes (r, l, 4); (* Symbol file tag *)
- IF l # SymTag THEN OutStr1 (s.msg12, symPath); HALT (d.warn)
- END;
-
- f.Read (r, si);
- IF si # eMod THEN OutStr1 (s.msg13, symPath); HALT (d.warn)
- END;
-
- ReadModAnchor (modKey, name);
- IF str2.CompareCAP (modName, name) # 0 THEN
- OutStr1 (s.msg14, symPath); HALT (d.warn)
- END;
- IF (key # 0) & (key # modKey) THEN
- OutStr1 (s.msg15, symPath); HALT (d.warn)
- END;
- NewModule (modName, objPath, modKey);
-
- LOOP
- f.Read (r, si);
- IF si # eMod THEN EXIT END;
- ReadModAnchor (modKey, name);
- Process (name, modKey)
- END;
-
- WHILE si = eExtLib DO
- ReadName (name);
- node := moduleList.Find (name);
- IF node = NIL THEN
- IF ~du.Search (ObjSearch, name, objPath) THEN
- OutStr1 (s.msg21, objPath); HALT (d.warn)
- END;
- NewModule (name, objPath, 0)
- END;
- f.Read (r, si)
- END;
-
- f.Set (r, NIL, 0); f.Close (symFile)
- ELSE
- OutStr1 (s.msg16, modName); HALT (d.warn)
- END
- ELSE
- OutStr1 (s.msg17, modName); HALT (d.warn)
- END
- ELSE
- IF (key # 0) & (node (ModulePtr).key # key) THEN
- OutStr1 (s.msg18, modName); HALT (d.warn)
- END
- END
- END Process;
-
- (*------------------------------------*)
- PROCEDURE Output ();
-
- VAR
- withFile : f.File; w : f.Rider;
- module : L.NodePtr; ch : CHAR;
-
- (*------------------------------------*)
- PROCEDURE Indent ();
- BEGIN (* Indent *)
- f.Write (w, " "); f.Write (w, " ")
- END Indent;
-
- (*------------------------------------*)
- PROCEDURE WriteStr (string : ARRAY OF CHAR);
- <*$CopyArrays-*>
- BEGIN (* WriteStr *)
- f.WriteBytes (w, string, str.Length (string))
- END WriteStr;
-
- (*------------------------------------*)
- (*
- Produces a .with file with the format:
-
- FROM <moduleName>.obj
- LIBRARY <first imported module>*
- {<other imported modules>*}
- TO <moduleName>
-
- *)
- PROCEDURE OutputALink ();
-
- BEGIN (* OutputALink *)
- f.Set (w, withFile, 0);
- module := moduleList.head;
- WriteStr ("FROM ");
- WriteStr (module(ModulePtr).path); f.Write (w, "\n");
- module := module.succ;
- WriteStr ("LIBRARY "); WriteStr (module(ModulePtr).path);
- module := module.succ;
- WHILE module # NIL DO
- f.Write (w, "*"); f.Write (w, "\n");
- Indent (); WriteStr (module(ModulePtr).path);
- module := module.succ
- END;
- f.Write (w, "\n"); WriteStr ("TO ");
- WriteStr (progName); f.Write (w, "\n");
- f.Set (w, NIL, 0);
- END OutputALink;
-
- (*------------------------------------*)
- (*
- Produces a .with file with the format:
-
- FROM
- <moduleName>.Obj
- LIBRARY
- {<imported modules>}
- TO
- <moduleName>
-
- *)
- PROCEDURE OutputBLink ();
-
- BEGIN (* OutputBLink *)
- f.Set (w, withFile, 0);
- module := moduleList.head;
- WriteStr ("FROM\n");
- Indent (); WriteStr (module(ModulePtr).path); f.Write (w, "\n");
- module := module.succ;
- WriteStr ("LIBRARY\n");
- WHILE module # NIL DO
- Indent (); WriteStr (module(ModulePtr).path); f.Write (w, "\n");
- module := module.succ
- END;
- WriteStr ("TO\n");
- Indent (); WriteStr (progName); f.Write (w, "\n");
- f.Set (w, NIL, 0);
- END OutputBLink;
-
- (*------------------------------------*)
- (*
- Produces a .with file with the format:
-
- <moduleName>.Obj
- {<imported modules>}
- *)
- PROCEDURE OutputDLink ();
-
- BEGIN (* OutputDLink *)
- f.Set (w, withFile, 0);
- module := moduleList.head;
- WHILE module # NIL DO
- WriteStr (module(ModulePtr).path); f.Write (w, "\n");
- module := module.succ
- END;
- f.Set (w, NIL, 0);
- END OutputDLink;
-
- BEGIN (* Output *)
- withFile := f.New (withName);
- IF withFile # NIL THEN
- IF OLSettings.WithFmt = OLSettings.ALink THEN OutputALink ()
- ELSIF OLSettings.WithFmt = OLSettings.BLink THEN OutputBLink ()
- ELSE OutputDLink ()
- END;
- f.Register (withFile);
- OutStr ("\x9B\x4B >> "); OutStr (withName); OutLn;
- IF OLSettings.MakeIcons THEN MakeIcon (withName, iconWith) END
- ELSE
- OutStr1 (s.msg19, withName)
- END
- END Output;
-
- (*------------------------------------*)
- PROCEDURE DoLink ();
-
- VAR command : ARRAY 256 OF CHAR;
-
- BEGIN (* DoLink *)
- IF OLSettings.LinkCmd # "" THEN COPY (OLSettings.LinkCmd, command)
- ELSIF OLSettings.WithFmt = OLSettings.ALink THEN command := "ALink"
- ELSIF OLSettings.WithFmt = OLSettings.BLink THEN command := "BLink"
- ELSE (* OLSettings.WithFmt = OLSettings.DLink *) command := "dlink"
- END;
- IF OLSettings.WithFmt = OLSettings.DLink THEN
- str.Append (" -o ", command);
- str.Append (progName, command);
- str.Append (" @", command)
- ELSE
- str.Append (" WITH ", command)
- END;
- str.Append (withName, command);
- IF OLSettings.LinkArgs # "" THEN
- str.Append (" ", command); str.Append (OLSettings.LinkArgs, command)
- END;
- IF d.SystemTags (command, 0) = 0 THEN
- IF OLSettings.MakeIcons THEN MakeIcon (progName, iconProg) END
- ELSE
- OutStr1 (s.msg20, command)
- END
- END DoLink;
-
- BEGIN (* Main *)
- OutStr (OLRev.vString);
- OutStr (CopyrightStr);
- OutStr0 (s.msg8);
- OutLn;
-
- IF Kernel.fromWorkbench THEN WbArgs()
- ELSE CliArgs()
- END;
- ParseArgs();
-
- IF OLSettings.Verbose THEN
- OutStr ("Program : "); OutStr (progName); OutLn;
- OutStr ("Linker : ");
- CASE OLSettings.WithFmt OF
- OLSettings.ALink : OutStr ("ALink") |
- OLSettings.BLink : OutStr ("BLink") |
- OLSettings.DLink : OutStr ("DLink") |
- END;
- OutLn;
- END;
-
- IF Scan THEN
- IF OLSettings.Verbose THEN OutLn; OutStr ("Scanning..."); OutLn; END;
- Process (moduleName, 0);
- Process ("Kernel", 0);
- Output ();
- OutLn
- END;
-
- IF Link THEN
- IF OLSettings.Verbose THEN
- OutStr ("LinkCmd : "); OutStr (OLSettings.LinkCmd); OutLn;
- OutStr ("LinkArgs : "); OutStr (OLSettings.LinkArgs); OutLn; OutLn;
- OutStr ("Linking..."); OutLn
- END;
- DoLink ()
- END
- END Main;
-
- BEGIN (* OL *)
- ASSERT (e.SysBase.libNode.version >= 37);
- Errors.Init;
- Init ();
- Main ()
- END OL.
-
- (***************************************************************************
-
- $Log: OL.mod $
- Revision 2.8 1995/01/26 02:07:58 fjc
- - Release 1.5
-
- Revision 2.7 1995/01/09 14:48:31 fjc
- - Modified console output.
- - Removed icon name arguments from command line.
- - Implemented Workbench arguments.
- - Added MakeIcon() to create icons for .with files and
- programs.
-
- Revision 2.6 1995/01/06 16:32:19 fjc
- - Now uses ReadArgs() to process command line arguments.
- - Completely new command line template with numerous options.
- - Loads settings from preferences file.
- - Seperate search paths for symbol and object files.
- - Multiple extensions for symbol and object files supported.
- - Improved support for Matt Dillon's dlink.
-
- Revision 2.5 1994/11/17 11:38:35 fjc
- - Uses Out instead of StdIO.
- - Uses new Strings modules.
-
- Revision 2.4 1994/09/25 18:29:32 fjc
- - Uses new syntax for external code declarations
-
- Revision 2.3 1994/09/03 16:30:49 fjc
- - Gets version string from OLRev.
-
- Revision 2.1 1994/07/03 14:59:27 fjc
- - Added option to call linker direct from OL.
-
- ***************************************************************************)
-